package src.main.java.com.health.coupon.controller;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import src.main.java.com.health.coupon.utils.JwtTokenUtils;


import java.util.Date;



@RestController
public class LoginController {


    @GetMapping("/login")
    public Response login(String phone, String code){
        Response response = new Response();
        //调用阿里云短信接口实现 code="1234"
        //根据商户手机号获取商户id
        if(code.equals("1234")){
            //根据手机号去后台查询商户，获取id id=21
            Date date = DateUtils.addHours(new Date(), 2);
            String token = JwtTokenUtils.generateToken(phone, "21", date);
            response.setData(token);
        }
        return response;
    }
}
